<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
  <div>当前数据: [1,2,3,4,5,20]</div>
  <input type="text" id="xInput" placeholder="X坐标">
  <input type="text" id="yInput" placeholder="Y坐标">
  <button onclick="addPoint()">添加点</button>
  <div id="graph"></div>
  <script>
    let xData = [1, 2, 3, 4, 5];
    let yData = [1, 3, 6, 10, 25];
    let layout = {
      title: 'Plotly数据可视化',
      xaxis: { title: 'X' },
      yaxis: { title: 'Y' },
      width: 400,
      height: 300
    };
    Plotly.newPlot('graph', [{ x: xData, y: yData, mode: 'lines+markers' }], layout);
    function addPoint() {
      let x = parseFloat(document.getElementById('xInput').value);
      let y = parseFloat(document.getElementById('yInput').value);
      xData.push(x);
      yData.push(y);
      Plotly.update('graph', { x: [xData], y: [yData] });
      document.getElementById('xInput').value = '';
      document.getElementById('yInput').value = '';
    }
  </script>
</body>
</html>